﻿<UserControl x:Class="SamplePresentation.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:doc="http://schemas.firstfloorsoftware.com/documenttoolkit"
    xmlns:dte="http://schemas.firstfloorsoftware.com/documenttoolkit/extensions"
    xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

    <Border Background="{StaticResource DarkBackground}" BorderBrush="Black" BorderThickness="1" MouseWheel="LayoutRoot_MouseWheel" KeyDown="Border_KeyDown">
        <Grid x:Name="LayoutRoot">
            <Grid.Resources>
                <dte:NullToVisibilityConverter x:Key="NullToVisibilityConverter" />
            </Grid.Resources>
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            
            <doc:DocumentDataSource x:Name="DataSource" DefaultThumbnailMaxSize="158,158" />

            <toolkit:TransitioningContentControl x:Name="ContentControl" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" TransitionCompleted="Content_TransitionCompleted">
                <Border x:Name="PageViewerBorder" Background="White" BorderBrush="Black" BorderThickness="1" Margin="4,4,4,0" HorizontalAlignment="Center" VerticalAlignment="Center"
                        Visibility="{Binding DataSource.Document, Converter={StaticResource NullToVisibilityConverter}}">
                    <doc:FixedPageViewer x:Name="PageViewer"
                                 DataContext="{Binding Page}"
                                 FixedPage="{Binding FixedPage}" 
                                 FixedPageSize="{Binding FixedPageSize}"
                                 FixedPageError="{Binding FixedPageError}"
                                 Scale="{x:Null}">
                        <i:Interaction.Behaviors>
                            <doc:NavigationBehavior TextContainer="{Binding}" />
                        </i:Interaction.Behaviors>
                    </doc:FixedPageViewer>
                </Border>
            </toolkit:TransitioningContentControl>

            <doc:ThumbnailListBox x:Name="Thumbnails" 
                                  DocumentDataSource="{Binding DataSource}"
                                  PageIndex="{Binding PageIndex, Mode=TwoWay}">
                <doc:ThumbnailListBox.RenderTransform>
                    <TranslateTransform x:Name="ThumbnailsTranslate" X="-10000" />
                </doc:ThumbnailListBox.RenderTransform>
            </doc:ThumbnailListBox>

            <HyperlinkButton Grid.Row="1" Content="© First Floor Software" Foreground="Silver" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="4" TargetName="_blank" NavigateUri="http://firstfloorsoftware.com" />

            <StackPanel Grid.Row="1" Orientation="Horizontal" Margin="0,8,0,8" HorizontalAlignment="Center">
                <Border Style="{StaticResource ButtonBorder}">
                    <Button x:Name="ToggleContent" Style="{StaticResource OpacityButton}" Width="16" Click="ToggleContent_Click">
                        <Button.Content>
                            <Path Data="M 0,0 L 0,2 L 2,2 L 2,0 Z M 0,3 L 0,5 L 2,5 L 2,3 Z M 3,0 L 3,2 L 5,2 L 5,0 Z M 3,3 L 3,5 L 5,5 L 5,3 Z" Width="9" Height="9" Fill="#202020" Stretch="Fill" />
                        </Button.Content>
                    </Button>
                </Border>

                <doc:PageNavigator x:Name="Navigator"
                                   Margin="8,0,0,0"
                                   PageCount="{Binding DataSource.Document.PageCount}"
                                   PageIndex="{Binding PageIndex, Mode=TwoWay}"/>
            </StackPanel>
        </Grid>
    </Border>
</UserControl>
